import random

from lib.Item.Item import Item


class Drops(object):
    def __init__(self, items):
        super(Drops, self).__init__()
        self.items = []
        for item in items:
            self.items.append(DropsItem(item['id'], item['point']))

    def get_num(self):
        return len(self.items)

    def get_drops(self):
        drops = []
        items = self.items
        for item in items:
            point = random.randint(0, 100)
            if item.point >= point:
                drops.append(Item(item.id))
                items.remove(item)
        return drops


class DropsItem(Item):
    def __init__(self, id, point):
        super(DropsItem, self).__init__(id)
        self.point = point
